<?php

class Sgit_Util_removeFiles
{

    static public function run($tabla, $key, $id,$borrar)
    {
        if(is_null($borrar)) return true;

        $files= Sgit_Util_getFiles::run($tabla, $key, $id,true);

        if($borrar=='delete'){
            
            foreach((array)$files as $file)
            {
                unlink($file['pathname']);
            }
            if(file_exists($file['dirname'])) rmdir($file['dirname']);
            
        }else{
            foreach((array)$borrar as $i)
            {
                unlink($files[$i]['pathname']);
            }
        }
        
        
        
    }
}
